package programmercarl.贪心.C8;

class Solution {
    public int jump(int[] nums) {
        //这里的覆盖范围内任意一个都能够跳，
        if (nums.length == 0||nums.length == 1) {return 0;}
        int currScope = 0;
        int maxScope = 0;
        int count = 0;
        for (int i = 0; i < nums.length; i++) {
            maxScope = Math.max(maxScope, nums[i] + i);
            //到了最大的scope了
            if (currScope >= nums.length-1) {
                count++;
                return count;
            }

            //如果走到当前scope最后了，还没有覆盖最后一个点，那么需要扩大scope
            if (i == currScope) {
                currScope=maxScope;
                count++;//走一步
            }
        }
        return count;
    }
}